package com.shumm.controller;

import com.shumm.common.Result;
import com.shumm.po.Traditionalchinesemedicine;
import com.shumm.service.TraditionalchinesemedicineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author shumm
 * @Description
 * @create 2023-11-17 17:15
 */
@RestController
@RequestMapping("/tcm")
@SuppressWarnings("all")
public class TraditionalchinesemedicineController {

    @Autowired
    private TraditionalchinesemedicineService service;

    @GetMapping("/list/{num}/{size}")
    private Result list(@PathVariable int num, @PathVariable int size) {
        return service.list(num, size);
//        return Result.success(service.list(num, size));
    }


    @GetMapping("/selectbc")
    public Result selectByCondition(@RequestParam String name,
                                    @RequestParam String alias,
                                    @RequestParam String xingwei,
                                    @RequestParam String zhuzhi,
                                    @RequestParam int num,
                                    @RequestParam int size) {
        return service.selectByCondition(name, alias, xingwei, zhuzhi, num, size);
    }

    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable int id) {
        return service.deleteByIdWithForeign(id);
    }

    @PostMapping("/update")
    public Result update(@RequestBody Traditionalchinesemedicine tcm) {
        return service.update(tcm);
    }

    @PostMapping("/add")
    public Result add(@RequestBody Traditionalchinesemedicine tcm) {
        return service.add(tcm);
    }

    @GetMapping("/listwc")
    public Result listWithContent(@RequestParam int id) {
        return service.listWithContent(id);
    }

    @GetMapping("/select")
    public Result selectById(@RequestParam int id) {
        return service.selectById(id);
    }
}
